<template>
  <div class="comment-wrapper">
    <div class="items">
      <div class="item" v-for="(item,index) in commentList" :key="'comment'+index">
        <div class="left">
          <img :src="item.user.avatarUrl" alt="">
        </div>
        <div class="right">
          <div class="top">
            <span class='user'>{{ item.user.nickname }}</span>
            <span class='content'>{{ item.content }}</span>
          </div>
          <div class="bottom">
            <div class="time">2016年9月18日</div>
            <div class="like-wrapper">
                <span>👍</span>({{ item.likedCount }})
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import comments from '../mockdatas/comments'

export default {
  data(){
    return{
      commentList:[]
    }
  },
  created(){
    this.getCommentInfo()
  },
  methods:{
    //获取评论信息
    async getCommentInfo(){
      await this.$axios
        .get('comment/hot?id='+this.$route.params.id+'&type=0')
        .then(res => {
          console.log(res);
          this.commentList = res.data.hotComments
        })
        .catch(err => {
          console.log("请求错误");
          this.commentList = comments
        })
        console.log(this.commentList);
    },
  }
}
</script>

<style scoped>
@import "@/assets/css/comment.css";
</style>